import { mapGetters } from 'vuex'
import { moneyFormat } from '@/utils'


export default {
	
	data() {
		return {
			hasRequestAuth: true // 请求是返回的权限
		}
	},
	props: {
		/** 是公海 默认是客户 */
		isSeas: {
			type: Boolean,
			default: false
		}
	},

	computed: {
		...mapGetters(['allAuth']),
		
		// 能否查看详情
		canShowDetail() {
			if (!this.hasRequestAuth) {
				return false
			}
			return this.allAuth && this.allAuth.lawcase && this.allAuth.lawcase.read
		}
	},

	watch: {
		id: function() {
			if (this.canShowDetail) {
				this.getDetial()
			}
		}
	},

	mounted() {
		if (this.canShowDetail) {
			this.getDetial()
		}
	},

	methods: {
		/** 顶部头 操作 */
		detailHeadHandle(data) {
			console.log(data);
			if (data.type === 'delete') {
				this.hideView()
			}
			else if(data.type === 'update_susong' || 
					data.type === 'update_xingshi' || 
					data.type === 'update_fuwu' || 
					data.type === 'update_zixun' ){
				this.hideView()
			}
			
			this.$emit('handle', data)
		},
		moneyFormat(money) {
			return moneyFormat(money)
		}
	},

	deactivated: function() {}

}
